package cn.hs.service.impl;/**
 * @author Jovan Hou 2024/10/23
 **/

import cn.hs.entity.Article;
import cn.hs.entity.Articletype;
import cn.hs.entity.Fm;
import cn.hs.mapper.ArticletypeMapper;
import cn.hs.service.ArticleTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ArticleTypeServiceImpl
 * @Description TODO
 * @Author CnYuu
 * @Date 2024年10月23日 19:34
 * @Version 1.0
 */
@Service
public class ArticleTypeServiceImpl implements ArticleTypeService
{
    @Autowired
    private ArticletypeMapper articletypeMapper;

    @Override
    public int insert(Articletype articletype)
    {

        return articletypeMapper.insert(articletype);
    }

    @Override
    public int deleteById(Integer id)
    {
        return articletypeMapper.deleteByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public int update(Articletype articletype)
    {
        return articletypeMapper.updateByPrimaryKey(articletype);
    }

    @Override
    public PageInfo findAll(Integer pageNum, Integer pageSize, Articletype articletype)
    {
        PageHelper.startPage(pageNum, pageSize);
        List<Articletype> articletypes = articletypeMapper.selectAll(articletype);
        PageInfo<Articletype> pageInfo = new PageInfo<>(articletypes);
        return pageInfo;
    }

    //外键查询
    @Override
    public PageInfo findbyForignId(Integer pageNum, Integer pageSize, Integer id)
    {
        PageHelper.startPage(pageNum, pageSize);
        List<Articletype> articles = articletypeMapper.selectAllByFId(id);
        PageInfo<Articletype> pageInfo = new PageInfo<>(articles);
        return pageInfo;
    }


}
